package com.hfy.kandian.controller;


import com.hfy.kandian.dao.command.WriterCommand;
import com.hfy.kandian.mapper.WriterMapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Writer;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HAN XIAOYANG
 * @since 2020-12-30
 */
@RestController
@RequestMapping("/writer")
public class WriterController {

    @Autowired
    WriterMapper writerMapper;

    @ApiOperation(value = "注册为作者")
    @PostMapping (value="/register")
    public int beWriter(@RequestBody WriterCommand writerCommand){
        return writerMapper.insert(writerCommand.convertToWriter());
    }

    @ApiOperation(value = "判断是否为作者（1是、0否）")
    @GetMapping(value = "/isWriter/{writerId}")
    public int isWriter(@PathVariable int writerId){
        return writerMapper.selectById(writerId)==null?0:1;
    }




}

